package com.cyq.day23.string;

public class Test {
    public static void main(String[] args) {
       //1.将下面字符串的首字母转换为大写
//        String s2="";
//        String s="pingyuan is a handsome boy";
//        String[] s1=s.split(" ");
//        for (int i = 0; i < s1.length; i++) {
//          s2+=s1[i].substring(0,1).toUpperCase()+s1[i].substring(1)+" ";
//        }
//        System.out.println(s2);
//        String s="pingyuan is a handsome boy";
//        char[] c=s.toCharArray();
//        for (int i = 0; i <c.length ; i++) {
//            if (i==0){
//                c[i]-=32;
//            }
//            if(c[i]==' '){
//                c[i+1]-=32;
//            }
//        }
//        String s1= Arrays.toString(c);
//        System.out.println(s1);
        //2.有下面的基本书，已经按照字段顺序排序，现在想加入新书
        //Java Mybatis Object Spring Ying--->Kim
        String s="Java Mybatis Object Spring Ying";
        String news="Kim";
        String[] s1=s.split(" ");
        String[] s2 = new String[s1.length+1];
        boolean flag=false;
        for (int i = 0; i <s1.length ; i++) {
            if (s1[i].charAt(0)<news.charAt(0)){
                s2[i]=s1[i]+" ";
            }
            if (!flag){
                if (s1[i].charAt(0)>news.charAt(0)){
                    s2[i]=news+" ";
                    flag=true;
                }
            }else{
                    s2[i]=s1[i-1]+" ";
            }
        }
        s2[s2.length-1]=s1[s1.length-1];
        for (int i = 0; i <s2.length ; i++) {
            System.out.print(s2[i]);
        }
        StringBuilder stringBuilder=new StringBuilder();
        StringBuffer stringBuffer=new StringBuffer();
    }
}
